#include "MsgManager.h"

namespace RobotControl{
namespace Common{
class MsgImp : public IMsgManager
{
public:
	MsgImp() : m_context(0)
	{}
	~MsgImp(){}

	///\brief 获取contex
	virtual zmq::context_t *getContext()
	{
		return &m_context;
	}

private:
	zmq::context_t m_context;
};

/// \brief 配置组建
bool MsgManager::config(const Json::Value &config)
{
	return true;
}

/// \brief 启动
bool MsgManager::start()
{
	std::lock_guard<std::mutex> locker(m_mutex);
	m_default_ptr = std::make_shared<MsgImp>();
	std::cout << "MsgManager started >>>>>>>>>";
	return true;
}

/// \brief 停止
bool MsgManager::stop()
{
	std::lock_guard<std::mutex> locker(m_mutex);
	m_default_ptr.reset();
	std::cout << "<<<<<<<<<<< MsgManager stopped";
	return true;
}

/// \brief 获取MsgManager
IMsgManagerPtr MsgManager::getInstance()
{
	std::lock_guard<std::mutex> locker(m_mutex);
	return m_default_ptr;
}

/// \brief 获取MsgManager
/// NOTE: 不支持
IMsgManagerPtr getInstance(const std::string &id)
{
	return nullptr;
}

}
}